﻿package ar.uba.fi.tonyvaliente.text.filtering;

import java.util.HashMap;
import java.util.LinkedList;

public class AcutesFilter implements TextFilter {

	@Override
	public LinkedList<String> filter(LinkedList<String> text) {
		LinkedList<String> result = new LinkedList<String>();

		HashMap<Character, Character> replace = new HashMap<Character, Character>();
		replace.put('á', 'a');
		replace.put('â', 'a');
		replace.put('ä', 'a');
		replace.put('à', 'a');
		replace.put('é', 'e');
		replace.put('ê', 'e');
		replace.put('ë', 'e');
		replace.put('è', 'e');
		replace.put('í', 'i');
		replace.put('î', 'i');
		replace.put('ï', 'i');
		replace.put('ì', 'i');
		replace.put('ó', 'o');
		replace.put('ô', 'o');
		replace.put('ö', 'o');
		replace.put('ò', 'o');
		replace.put('ú', 'u');
		replace.put('û', 'u');
		replace.put('ü', 'u');
		replace.put('ù', 'u');

		for (String s : text) {
			String filtered = s;
			for (Character oldChar : replace.keySet()) {
				Character newChar = replace.get(oldChar);
				filtered = filtered.replace(oldChar, newChar);
			}
			result.add(filtered);
		}
		return result;
	}
}
